#include "mytypes.h"
#include <unistd.h>
#include <iostream>
#include <QTextStream>
#include <QPair>
#include <QStringList>
#include <QVector>
#include <iostream>
namespace  Yzty{
    QString ROOTPW;
    QString PREMISSPN;
    int     LEVEL;
    QString CONFIGPATH="../conf/default/.config.txt";

    int ToolMapItemHashCode=0xff;

    bool FileCondtionFlag=false;               //文件条件选择的标记
    bool EmailCondionFlag=false;               //邮件机检查标记
    bool VirConditionFlag=false;               //虚拟机检查标记
    bool DeepCondtionFlag=false;


    bool VerifyRootPW(const QString& pw){
        FILE* fp=popen(QString("echo %1 | sudo -S su").arg(pw).toLocal8Bit(),"r");
        QTextStream fstream(fp);
        if(fstream.readAll().contains("验证成功"))
            return true;
        return false;
    }

    bool VerifyPerMission(const QString& premissionnum){
        return premissionnum.size();
    }


    QTextStream& GetTextSteam(const QString& paths){
        FILE* fp=fopen(paths.toLocal8Bit(),"r");
        QTextStream* fstrema=new QTextStream(fp);
        return *fstrema;
    }

    QMap<QString,QString> ConfigParse_Head(const QStringList& text){
        int n=text.size();
        if(n==0)
            return QMap<QString,QString>();

        QStringList temp=text[0].split('\n');
        temp.removeFirst();

        QMap<QString,QString> ret;
        for(QString& item:temp){
            if(item.isEmpty())
                continue;
            QStringList t=item.split(':');
            ret[t[0]]=t[1];
        }
        return ret;
    }

    QMap<int,QPair<QString,QStringList>> ConfigParse_Body(const QStringList& text){
        int n=text.size();
        QMap<int,QPair<QString,QStringList>> ret;
        if(n>=2){
            QStringList items=text[1].split('>');
            items.removeFirst();
            for(int i=0;i<items.size();i++){
                QStringList temp=items[i].split('\n');
                ret[i].first=temp[0];
                temp.removeFirst();
                for(QString& t:temp)
                    if(!t.isEmpty())        //去掉空值
                        ret[i].second.push_back(t);
            }
        }
        return ret;
    }
    QMap<int,QVector<QPair<QString,QStringList>>> ConfigParse_Struct(const QStringList& text){
        int n=text.size();
        QMap<int,QVector<QPair<QString,QStringList>>> ret;

        if(n>=3){
            QStringList item=text[2].split('>');
            item.removeFirst();

            for(int i=0;i<item.size();i++){
                QStringList temp=item[i].split('\n');
                temp.removeFirst();

                for(QString& it:temp){
                    if(it.isEmpty())
                        continue;
                    QStringList itt=it.split(':');
                    QPair<QString,QStringList> p;
                    p.first=itt[0];
                    QStringList tp=itt[1].split(QChar(' '));
                    for(QString& ittt:tp)
                        if(!ittt.isEmpty())
                            p.second.push_back(ittt);

                    ret[i].push_back(p);
                }

            }
        }

        return ret;
    }


}

namespace Yzty {
/*****************基础信息类*******************/
    BaceInfor::BaceInfor(ToolCode tcode,uint16_t mcode):_toolcode(tcode),_modelindex(mcode)
    {

    }

    BaceInfor::~BaceInfor()
    {

    }

    ToolCode BaceInfor::GetToolCode()
    {
        return _toolcode;
    }

    uint16_t BaceInfor::GetModelCode()
    {
        return _modelindex;
    }


    QString& BaceInfor::GetItem(int)
    {
        return this->_descripe;
    }

}

namespace Yzty{

    SystemSoftList::SystemSoftList(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(Nums)){

    }

    MirrorFile::MirrorFile(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(Nums)){

    }

    IpAddressInfor::IpAddressInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(Nums)){

    }

    HostInfor::HostInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode) {

    }

    PhonePlugInfor::PhonePlugInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(Nums)){

    }
    HardPartInfor::HardPartInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(Nums)){

    }
}

/***************************************硬件检查类型定义********************************************/

//命令行字段读取定义
namespace Yzty
{
/*********************************************************/
    QString biosInfor::Vendor               ="Vendor";
    QString biosInfor::Version              ="Version";
    QString biosInfor::RuntimeSize          ="Runtime Size";
    QString biosInfor::ROMSize              ="ROM Size";
    QString biosInfor::Features             ="Characteristics";

    QString mesoltInfor::Postion            ="Location";
    QString mesoltInfor::MaxCapacity        ="Maximum Capacity";
    QString mesoltInfor::NumDevice          ="Number Of Devices";

    QString moboInfor::Vendor               ="Manufacturer";
    QString moboInfor::ProductName          ="Product Name";
    QString moboInfor::Version              ="Version";
    QString moboInfor::SerialNumber         ="Serial Number";
    QString moboInfor::Type                 ="Type";
    QString moboInfor::Feature              ="Features";


    QString cpuInfor::ProductName           ="model name";
    QString cpuInfor::Vendor                ="vendor_id";
    QString cpuInfor::Model                 ="model";
    QString cpuInfor::CpuMHz                ="cpu MHz";
    QString cpuInfor::BogoMips              ="bogomips";
    QString cpuInfor::CoreId                ="core id";
    QString cpuInfor::Cores                 ="cpu cores";
    QString cpuInfor::processor             ="processor";

    QString memoryInfor::Vendor             ="Manufacturer";
    QString memoryInfor::ProductName        ="Part Number";
    QString memoryInfor::Type               ="Type";
    QString memoryInfor::SoltType           ="Locator";
    QString memoryInfor::SerialNumber       ="Serial Number";
    QString memoryInfor::MemorySize         ="Volatile Size";
    QString memoryInfor::DataWidth          ="Data Width";
    QString memoryInfor::Speed              ="Speed";                       //读入输入
    QString memoryInfor::Mhz                ="Configured Memory Speed";     //配置频率

    QString graphcardInfor::ProductName     ="product";
    QString graphcardInfor::Vendor          ="vendor";
    QString graphcardInfor::Descript        ="description";
    QString graphcardInfor::Version         ="version";
    QString graphcardInfor::Ability         ="capabilities";
    QString graphcardInfor::MHz             ="clock";
    QString graphcardInfor::DataWidth       ="width";
    QString graphcardInfor::CurReslution    ="current";
    QString graphcardInfor::MinReslution    ="minimum";
    QString graphcardInfor::MaxReslution    ="maximum";

    QString graphcardInfor::Model           ="Model";
    QString graphcardInfor::Drive           ="Driver";
    QString graphcardInfor::IoPort          ="I/O Ports";
    QString graphcardInfor::Config          ="Config Status";
    QString graphcardInfor::Interface       ="Attached to";

    QString networkcardInfor::ProductName   ="product";
    QString networkcardInfor::Vendor        ="vendor";
    QString networkcardInfor::Type          ="description";
    QString networkcardInfor::Version       ="version";
    QString networkcardInfor::Ability       ="capabilities";
    QString networkcardInfor::DataWidth     ="width";
    QString networkcardInfor::Config        ="configuration";   //配置信息
    QString networkcardInfor::Mhz           ="clock";
    QString networkcardInfor::Resource      ="resources";
    QString networkcardInfor::Serial        ="serial";
    QString networkcardInfor::logicalname   ="logical name";

    QString keyboardInfor::ProductName      ="Device";
    QString keyboardInfor::Vendor           ="Vendor";
    QString keyboardInfor::Type             ="Model";
    QString keyboardInfor::Interface        ="Attached to";
    QString keyboardInfor::Hwclass          ="Hardware Class";
    QString keyboardInfor::Config           ="Config Status";

    QString mouseInfor::ProductName         ="Device";
    QString mouseInfor::Vendor              ="Vendor";
    QString mouseInfor::Type                ="Model";
    QString mouseInfor::Interface           ="Attached to";
    QString mouseInfor::Hwclass             ="Hardware Class";
    QString mouseInfor::Config              ="Config Status";

    QString batteryInfor::ProductName       ="model";
    QString batteryInfor::Vendor            ="vendor";
    //QString batteryInfor::Version           ="version";
    QString batteryInfor::SerialNum         ="serial";
    QString batteryInfor::UpdateTime        ="updated";
    QString batteryInfor::State             ="state";
    QString batteryInfor::Energy            ="energy";
    QString batteryInfor::FullEnergy        ="energy-full";
    QString batteryInfor::DesihmFullEnergy  ="energy-full-design";
    QString batteryInfor::RateEnergy        ="energy-rate";
    QString batteryInfor::Volatage          ="voltage";
    QString batteryInfor::Percentage        ="percentage";
    QString batteryInfor::Capacity          ="capacity";


    QString soundcardInfor::ProductName     ="product";
    QString soundcardInfor::Vendor          ="vendor";
    QString soundcardInfor::Type            ="description";
    QString soundcardInfor::Version         ="version";
    QString soundcardInfor::Ability         ="capabilities";
    QString soundcardInfor::Config          ="configuration";
    QString soundcardInfor::Mhz             ="clock";
    QString soundcardInfor::DataWidth       ="width";

    QString diskInfor::ProductName          ="Model";
    QString diskInfor::Vendor               ="Vendor";
    QString diskInfor::Medium;
    QString diskInfor::Interface            ="Attached to";
    QString diskInfor::Serialnum            ="Serial ID";
    QString diskInfor::Driver               ="Driver";
    QString diskInfor::DeviceFile           ="Device File";
    QString diskInfor::Config               ="Config Status";
    QString diskInfor::Hwclass              ="Hardware Class";
    QString diskInfor::Size                 ="Capacity";

    QString bluetoothInfor::ProductName     ="Model";
    QString bluetoothInfor::Vendor          ="Vendor";
    QString bluetoothInfor::Interface       ="Attached to";
    QString bluetoothInfor::Driver          ="Driver";
    QString bluetoothInfor::Config          ="Config Status";
    QString bluetoothInfor::Hwclass         ="Hardware Class";
    QString bluetoothInfor::Speed           ="Speed";
    /**********************命令存取字段定义************************************/

    QString osInfor::Machinename            ="Product Name";
    QString osInfor::Vendor                 ="Manufacturer";
    QString osInfor::UUID                   ="UUID";


    int userInfor::Uname                    =0;
    int userInfor::Tty                      =1;
    int userInfor::Logtime                  =2;
    int userInfor::Pcpu                     =5;
    int userInfor::What                     =6;

};

//输出字段
namespace Yzty
{
    QStringList cpuInfor::keywords
    {
        "名称",
        "制造商",
        "处理器ID",
        "核心ID",
        "核心数",
        "当前频率",
        "BogoMIPS",
        "架构",
        "型号",
        "字长",
        "数据存储模式"
    };

    QStringList biosInfor::keywords
    {
        "制造商",
        "版本",
        "ROM",
        "运行内存",
        "特性"
    };

    QStringList mesoltInfor::keywords
    {
        "位置",
        "卡槽数量",
        "最大容量"
    };

    QStringList moboInfor::keywords
    {
        "名称",
        "制造商",
        "版本",
        "类型",
        "序列号",
        "特性"
    };

    QStringList memoryInfor::keywords
    {
        "名称",
        "制造商",
        "型号",
        "大小",
        "序列号",
        "速度",
        "数据位宽",
        "配置频率",
        "插槽类型"
    };

    QStringList graphcardInfor::keywords
    {
        "名称",
        "制造商",
        "型号",
        "版本",
        "位宽",
        "功能",
        "接口",
        "频率",
        "描述",
        "驱动模块",
        "当前分辨率",
        "最大分辨率",
        "最小分辨率",
        "IO端口",
        "配置信息"
    };

    QStringList soundcardInfor::keywords
    {
        "名称",
        "制造商",
        "型号",
        "版本",
        "功能",
        "配置",
        "频率",
        "位宽"
    };

    QStringList diskInfor::keywords
    {
        "名称",
        "制造商",
        "介质",
        "大小",
        "接口",
        "序列号",
        "驱动模块",
        "驱动文件",
        "配置信息",
        "硬件类型"
    };

    QStringList batteryInfor::keywords
    {
        "名称",
        "制造商",
        "序列号",
        "电池状态",
        "百分比",
        "当前能量",
        "总能量",
        "设计能量",
        "能量密度",
        "电压",
        "容量",
        "信息更新时间"
    };

    QStringList bluetoothInfor::keywords
    {
        "名称",
        "制造商",
        "驱动",
        "接口",
        "速度",
        "硬件类型",
        "配置信息"
    };

    QStringList networkcardInfor::keywords
    {
        "名称",
        "制造商",
        "类型",
        "版本",
        "频率",
        "数据位宽",
        "功能描述",
        "配置信息",
        "资源",
        "序列号",
        "逻辑名称"
    };

    QStringList mouseInfor::keywords
    {
        "名称",
        "制造商",
        "型号",
        "接口",
        "硬件类型",
        "配置信息"
    };

    QStringList keyboardInfor::keywords
    {
        "名称",
        "制造商",
        "型号",
        "接口",
        "硬件类型",
        "配置信息"
    };

    QStringList osInfor::keywords
    {
        "机器名称",
        "制造商",
        "系统名称",
        "版本",
        "系统类型",
        "内核类型",
        "内核版本",
        "处理器信息",
        "UUID"
    };

    QStringList userInfor::keywords
    {
        "用户名",
        "终端号",
        "登陆时间",
        "执行时间",
        "执行命令"
    };

}
namespace Yzty{
    QStringList HostInfo::Keywords {
        "OSVersion",
        "InstallTime",
        "HostName",
        "Type",
        "Description",
        "Xxx"
    };
    QStringList HostInfo::defaultinfo{
        "操作系统版本",
        "安装时间",
        "主机名",
        "主机类型",
        "描述",
        "自定义字段",
    };
    QStringList AccountInfo::Keywords{
        "CurrentUser"
    };
    QStringList AccountInfo::defaultinfo{
        "当前账户"
    };
    QStringList NetWorkInfo::Keywords{
        "IP",
        "Mac",
    };
    QStringList NetWorkInfo::defaultinfo{
        "主机IP地址",
        "主机MAC地址"
    };
    QStringList HardDiskInfo::Keywords{
        "Company",
        "Product",
        "SN",
        "TotalDiskSpace",
        "Detail",
        "BootTimes",
        "Using",
        "Status",
    };
    QStringList HardDiskInfo::defaultinfo{
        "厂商",
        "型号",
        "序列号",
        "总容量",
        "分区详细情况",
        "启动次数",
        "启动时间",
        "状态",
    };
    QStringList FastUSBRecord::Keywords{
        "Type",
        "DeviceName",
        "SN",
        "VID",
        "PID",
        "FirstDate",
        "LastDate",
        "Deduction",
    };
    QStringList FastUSBRecord::defaultinfo{
        "设备类型",
        "设备名称",
        "序列号",
        "设备ID",
        "产品ID",
        "首次使用时间",
        "最后使用时间",
        "违规参考",
    };
    QStringList DeepUSBRecord::Keywords{
        "Type",
        "DeviceName",
        "SN",
        "VID",
        "PID",
        "FirstDate",
        "LastDate",
        "Deduction",
    };
    QStringList DeepUSBRecord::defaultinfo{
        "设备类型",
        "设备名称",
        "序列号",
        "设备ID",
        "产品ID",
        "首次使用时间",
        "最后使用时间",
        "违规参考",
    };
    QStringList FastInternetRecord::Keywords{
        "Date",
        "Name",
        "Process",
        "Deduction",
        "Xxx",
    };
    QStringList FastInternetRecord::defaultinfo{
        "上网时间",
        "软件名称",
        "相关进程",
        "违规参考",
        "自定义扩展",
    };
    QStringList DeepInternetRecord::Keywords{
        "Date",
        "Name",
        "Process",
        "Deduction",
        "Xxx",
    };
    QStringList DeepInternetRecord::defaultinfo{
        "上网时间",
        "软件名称",
        "相关进程",
        "违规参考",
        "自定义扩展",
    };
    QStringList FastFileCheck::Keywords{
        "FileName",
        "FilePath",
        "FileSize",
        "ModifyDate",
        "CreateDate",
        "KeywordHit",
        "KeyAbstract",
        "Application",
        "Deduction",
        "JudgedMan",
        "JudgedRemark",
        "Level",
    };
    QStringList FastFileCheck::defaultinfo{
        "文件名称",
        "文件路径",
        "文件大小",
        "文件修改时间",
        "文件创建时间",
        "命中关键字",
        "关键词摘要",
        "文件所属应用",
        "违规参考",
        "密级初判人",
        "判定备注",
        "涉密类型",
    };
    QStringList DeepFileCheck::Keywords{
        "FileName",
        "FilePath",
        "FileSize",
        "ModifyDate",
        "CreateDate",
        "KeywordHit",
        "Application",
        "Deduction",
    };
    QStringList DeepFileCheck::defaultinfo{
        "文件名称",
        "文件路径",
        "文件大小",
        "文件修改时间",
        "文件创建时间",
        "命中关键字",
        "文件所属应用",
        "违规参考",
    };
    QStringList ShareFile::Keywords{
        "Name",
        "Path",
        "Authority",
        "Deduction",
    };
    QStringList ShareFile::defaultinfo{
        "共享名称",
        "文件路径",
        "共享权限",
        "违规参考",
    };
    QStringList SystemPatch::Keywords{
        "ID",
        "Description",
        "VulDescription",
        "Date",
        "Deduction",
    };
    QStringList SystemPatch::defaultinfo{
        "补丁ID",
        "补丁描述",
        "漏洞描述",
        "补丁时间",
        "违规参考",
    };
    QStringList OSInstallation::Keywords{
        "Name",
        "Version",
        "InstallPath",
        "InstallDate",
        "Deduction",
    };
    QStringList OSInstallation::defaultinfo{
        "操作系统名称",
        "操作系统版本",
        "安装路径",
        "安装时间",
        "违规参考",
    };
    QStringList Antivirus::Keywords{
        "Name",
        "Version",
        "UpdateDate",
        "Deduction",
    };
    QStringList Antivirus::defaultinfo{
        "名称",
        "版本",
        "更新时间",
        "违规参考",
    };
    QStringList SWInstall::Keywords{
        "Name",
        "Company",
        "InstallTime",
    };
    QStringList SWInstall::defaultinfo{
        "名称",
        "厂商",
        "安装时间",
    };
    QStringList SpecialDefense::Keywords{
        "Name",
    };
    QStringList SpecialDefense::defaultinfo{
        "名称",
    };
    QStringList WirelessDevice::Keywords{
        "Name",
        "Company",
        "Description",
        "Type",
        "Deduction",
    };
    QStringList WirelessDevice::defaultinfo{
        "硬件名称",
        "厂商",
        "描述",
        "类型",
        "违规参考",
    };
    QStringList VirtualMachine::Keywords{
        "Name",
        "Version",
        "Company",
        "InstallPath",
        "InstallDate",
        "Deduction",
    };
    QStringList VirtualMachine::defaultinfo{
        "软件名称",
        "软件版本",
        "软件公司",
        "安装路径",
        "安装时间",
        "违规参考",
    };
    QStringList AccountStrategy::Keywords{
        "MinPasswordLength",
        "MaxValidityPeriod",
        "MinValidityPeriod",
        "PasswordHistory",
        "LockTime",
        "RestCounter",
        "GuestStatus",
        "AutoLogon",
        "Deduction",
    };
    QStringList AccountStrategy::defaultinfo{
        "口令长度最小值",
        "口令最长使用期限",
        "口令最短使用期限",
        "强制口令历史",
        "账户锁定时间",
        "复位账户锁定计数器",
        "Guest账户状态",
        "自动登录设置",
        "违规参考",
    };
    QStringList AccountSetting::Keywords{
        "UserName",
        "PasswordPrompt",
        "Deduction",
    };
    QStringList AccountSetting::defaultinfo{
        "帐户名",
        "口令设置情况",
        "违规参考",
    };
    QStringList AuditStrategy::Keywords{
        "Modify",
        "Login",
        "Object",
        "Process",
        "AD",
        "SpecialUse",
        "Event",
        "LoginOther",
        "Account",
        "Deduction",
    };
    QStringList AuditStrategy::defaultinfo{
        "审查策略更改",
        "审核登录事件",
        "审核对象访问",
        "审核过程跟踪",
        "审核目录服务访问",
        "审核权限使用",
        "审核系统事件",
        "审核账户登录事件",
        "审核账户管理",
        "违规参考",
    };
    QStringList AccountPermissionSetting::Keywords{
        "UserName",
        "PermissionPrompt",
        "Deduction",
    };
    QStringList AccountPermissionSetting::defaultinfo{
        "账户名",
        "账户权限设置情况",
        "违规参考",
    };
    QStringList Services::Keywords{
        "ServiceName",
        "PID",
        "PName",
        "Description",
        "Path",
        "Status",
        "Signature",
        "Auto",
        "Deduction",
    };
    QStringList Services::defaultinfo{
        "服务名称",
        "进程ID",
        "进程名称",
        "服务描述",
        "程序路径",
        "服务状态",
        "签名情况",
        "自启动情况",
        "违规参考",
    };
    QStringList Ports::Keywords{
        "Port",
        "Protocol",
        "LocalIP",
        "RemoteIP",
        "Status",
        "PID",
        "PName",
        "Deduction",
    };
    QStringList Ports::defaultinfo{
        "端口",
        "协议",
        "本地IP地址",
        "对端IP地址",
        "端口状态",
        "进程ID",
        "进程名称",
        "违规参考",
    };
    QStringList EmailCheck::Keywords{
        "attach",
        "AccountName",
        "EmailPosition",
        "EmailTitle",
        "EmailRecipient",
        "EmailSender",
        "EmailDate",
        "EmailSize",
    };
    QStringList EmailCheck::defaultinfo{
        "附件",
        "邮件账户",
        "邮件位置",
        "主题",
        "收件人",
        "发件人",
        "日期",
        "大小",
    };

    QStringList ComputerInfo::KeyWords{
        "处理器",
        "CPU主频",
        "物理核数量",
        "逻辑核数量",
        "主板型号",
        "内存信息",
        "电脑型号",
        "计算机名",
    };

    QStringList MemoryInfor::KeyWords {
        "频率",
        "型号",
        "容量",
        "制造商"
    };

    QStringList NetInfor::KeyWords {
        "网卡名称",
        "网卡信息",
        "网卡驱动",
        "当前MAC地址",
        "原始MAC地址",
        "IP",
        "DNS",
        "网关"
    };

    int XmlBaceInfo::GetSize() {return 0;}
    QString XmlBaceInfo::GetInfor(int) {return "";}
    QString XmlBaceInfo::GetKeyWords(int) {return "";}
    QString XmlBaceInfo::GetDefaultInfo(int) {return "";}

    int HostInfo::GetSize() {return NUMS;}
    QString HostInfo::GetInfor(int i) {return _infor[i];}
    QString HostInfo::GetKeyWords(int i) {return Keywords[i];}
    QString HostInfo::GetDefaultInfo(int i) {return defaultinfo[i];}

    int AccountInfo::GetSize() {return NUMS;}
    QString AccountInfo::GetInfor(int i) {return _infor[i];}
    QString AccountInfo::GetKeyWords(int i) {return Keywords[i];}
    QString AccountInfo::GetDefaultInfo(int i) {return defaultinfo[i];}

    int NetWorkInfo::GetSize() {return NUMS;}
    QString NetWorkInfo::GetInfor(int i) {return _infor[i];}
    QString NetWorkInfo::GetKeyWords(int i) {return Keywords[i];}
    QString NetWorkInfo::GetDefaultInfo(int i) {return defaultinfo[i];}

    int HardDiskInfo::GetSize() {return NUMS;}
    QString HardDiskInfo::GetInfor(int i) {return _infor[i];}
    QString HardDiskInfo::GetKeyWords(int i) {return Keywords[i];}
    QString HardDiskInfo::GetDefaultInfo(int i) {return defaultinfo[i];}

    int FastUSBRecord::GetSize() {return NUMS;}
    QString FastUSBRecord::GetInfor(int i) {return _infor[i];}
    QString FastUSBRecord::GetKeyWords(int i) {return Keywords[i];}
    QString FastUSBRecord::GetDefaultInfo(int i) {return defaultinfo[i];}

    int DeepUSBRecord::GetSize() {return NUMS;}
    QString DeepUSBRecord::GetInfor(int i) {return _infor[i];}
    QString DeepUSBRecord::GetKeyWords(int i) {return Keywords[i];}
    QString DeepUSBRecord::GetDefaultInfo(int i) {return defaultinfo[i];}

    int FastInternetRecord::GetSize() {return NUMS;}
    QString FastInternetRecord::GetInfor(int i) {return _infor[i];}
    QString FastInternetRecord::GetKeyWords(int i) {return Keywords[i];}
    QString FastInternetRecord::GetDefaultInfo(int i) {return defaultinfo[i];}

    int DeepInternetRecord::GetSize() {return NUMS;}
    QString DeepInternetRecord::GetInfor(int i) {return _infor[i];}
    QString DeepInternetRecord::GetKeyWords(int i) {return Keywords[i];}
    QString DeepInternetRecord::GetDefaultInfo(int i) {return defaultinfo[i];}

    int FastFileCheck::GetSize() {return NUMS;}
    QString FastFileCheck::GetInfor(int i) {return _infor[i];}
    QString FastFileCheck::GetKeyWords(int i) {return Keywords[i];}
    QString FastFileCheck::GetDefaultInfo(int i) {return defaultinfo[i];}

    int DeepFileCheck::GetSize() {return NUMS;}
    QString DeepFileCheck::GetInfor(int i) {return _infor[i];}
    QString DeepFileCheck::GetKeyWords(int i) {return Keywords[i];}
    QString DeepFileCheck::GetDefaultInfo(int i) {return defaultinfo[i];}

    int ShareFile::GetSize() {return NUMS;}
    QString ShareFile::GetInfor(int i) {return _infor[i];}
    QString ShareFile::GetKeyWords(int i) {return Keywords[i];}
    QString ShareFile::GetDefaultInfo(int i) {return defaultinfo[i];}

    int SystemPatch::GetSize() {return NUMS;}
    QString SystemPatch::GetInfor(int i) {return _infor[i];}
    QString SystemPatch::GetKeyWords(int i) {return Keywords[i];}
    QString SystemPatch::GetDefaultInfo(int i) {return defaultinfo[i];}

    int OSInstallation::GetSize() {return NUMS;}
    QString OSInstallation::GetInfor(int i) {return _infor[i];}
    QString OSInstallation::GetKeyWords(int i) {return Keywords[i];}
    QString OSInstallation::GetDefaultInfo(int i) {return defaultinfo[i];}

    int Antivirus::GetSize() {return NUMS;}
    QString Antivirus::GetInfor(int i) {return _infor[i];}
    QString Antivirus::GetKeyWords(int i) {return Keywords[i];}
    QString Antivirus::GetDefaultInfo(int i) {return defaultinfo[i];}

    int SWInstall::GetSize() {return NUMS;}
    QString SWInstall::GetInfor(int i) {return _infor[i];}
    QString SWInstall::GetKeyWords(int i) {return Keywords[i];}
    QString SWInstall::GetDefaultInfo(int i) {return defaultinfo[i];}

    int SpecialDefense::GetSize() {return NUMS;}
    QString SpecialDefense::GetInfor(int i) {return _infor[i];}
    QString SpecialDefense::GetKeyWords(int i) {return Keywords[i];}
    QString SpecialDefense::GetDefaultInfo(int i) {return defaultinfo[i];}

    int WirelessDevice::GetSize() {return NUMS;}
    QString WirelessDevice::GetInfor(int i) {return _infor[i];}
    QString WirelessDevice::GetKeyWords(int i) {return Keywords[i];}
    QString WirelessDevice::GetDefaultInfo(int i) {return defaultinfo[i];}

    int VirtualMachine::GetSize() {return NUMS;}
    QString VirtualMachine::GetInfor(int i) {return _infor[i];}
    QString VirtualMachine::GetKeyWords(int i) {return Keywords[i];}
    QString VirtualMachine::GetDefaultInfo(int i) {return defaultinfo[i];}

    int AccountStrategy::GetSize() {return NUMS;}
    QString AccountStrategy::GetInfor(int i) {return _infor[i];}
    QString AccountStrategy::GetKeyWords(int i) {return Keywords[i];}
    QString AccountStrategy::GetDefaultInfo(int i) {return defaultinfo[i];}

    int AccountSetting::GetSize() {return NUMS;}
    QString AccountSetting::GetInfor(int i) {return _infor[i];}
    QString AccountSetting::GetKeyWords(int i) {return Keywords[i];}
    QString AccountSetting::GetDefaultInfo(int i) {return defaultinfo[i];}

    int AuditStrategy::GetSize() {return NUMS;}
    QString AuditStrategy::GetInfor(int i) {return _infor[i];}
    QString AuditStrategy::GetKeyWords(int i) {return Keywords[i];}
    QString AuditStrategy::GetDefaultInfo(int i) {return defaultinfo[i];}

    int AccountPermissionSetting::GetSize() {return NUMS;}
    QString AccountPermissionSetting::GetInfor(int i) {return _infor[i];}
    QString AccountPermissionSetting::GetKeyWords(int i) {return Keywords[i];}
    QString AccountPermissionSetting::GetDefaultInfo(int i) {return defaultinfo[i];}

    int Services::GetSize() {return NUMS;}
    QString Services::GetInfor(int i) {return _infor[i];}
    QString Services::GetKeyWords(int i) {return Keywords[i];}
    QString Services::GetDefaultInfo(int i) {return defaultinfo[i];}

    int Ports::GetSize() {return NUMS;}
    QString Ports::GetInfor(int i) {return _infor[i];}
    QString Ports::GetKeyWords(int i) {return Keywords[i];}
    QString Ports::GetDefaultInfo(int i) {return defaultinfo[i];}

    int EmailCheck::GetSize() {return NUMS;}
    QString EmailCheck::GetInfor(int i) {return _infor[i];}
    QString EmailCheck::GetKeyWords(int i) {return Keywords[i];}
    QString EmailCheck::GetDefaultInfo(int i) {return defaultinfo[i];}

}

namespace Yzty
{
/**********************************************/
    cpuInfor::cpuInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

    QString& cpuInfor::GetItem(int itemindex)
    {
        switch (itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_procid;
            case 3:
                return this->_coreid;
            case 4:
                return this->_cores;
            case 5:
                return this->_fmhz;
            case 6:
                return this->_mips;
            case 7:
                return this->_arch;
            case 8:
                return this->_model;
            case 9:
                return this->_wordsize;
            case 10:
                return this->_end;
        }

        return this->_prodname;     //正常情况不会执行到这句
    }

/********************************************/
    QString& biosInfor::GetItem(int itemindex)
    {
        switch (itemindex)
        {
            case 0:
                return this->_vendorname;
            case 1:
                return this->_version;
            case 2:
                return this->_rom;
            case 3:
                return this->_runmemor;
            case 4:
                return this->_feature;
        }
        return this->_vendorname;
    }

    QString& mesoltInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_pos;
            case 1:
                return this->_solts;
            case 2:
                return this->_mgb;
        }
        return this->_pos;
    }

    QString& moboInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorame;
            case 2:
                return this->_version;
            case 3:
                return this->_model;
            case 4:
                return this->_serialnum;
            case 5:
                return this->_feature;
        }
        return this->_prodname;
    }

    moboInfor::moboInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}
/*********************************************/

    QString& memoryInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_model;
            case 3:
                return this->_mgb;
            case 4:
                return this->_serialnum;
            case 5:
                return this->_speed;
            case 6:
                return this->_dataw;
            case 7:
                return this->_mhz;
            case 8:
                return this->_slottype;
        }
        return this->_prodname;
    }

    memoryInfor::memoryInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

/*********************************************/

    QString& graphcardInfor::GetItem(int itemindex)
    {
        switch (itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_model;
            case 3:
                return this->_version;
            case 4:
                return this->_dataw;
            case 5:
                return this->_ability;
            case 6:
                return this->_interface;
            case 7:
                return this->_mhz;
            case 8:
                return this->_description;
            case 9:
                return this->_driver;
            case 10:
                return this->_curslt;
            case 11:
                return this->_maxslt;
            case 12:
                return this->_minslt;
            case 13:
                return this->_ioport;
            case 14:
                return this->_config;
        }
        return this->_prodname;
    }

    graphcardInfor::graphcardInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

/***********************************************/
    networkcardInfor::networkcardInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

    QString& networkcardInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorbname;
            case 2:
                return this->_model;
            case 3:
                return this->_version;
            case 4:
                return this->_mhz;
            case 5:
                return this->_dataw;
            case 6:
                return this->_ability;
            case 7:
                return this->_config;
            case 8:
                return this->_resource;
            case 9:
                return this->_Serial;
            case 10:
                return this->_logicalname;
            default:
                return this->_prodname;
        }
    }

/**************************************************/
    QString& diskInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_medium;
            case 3:
                return this->_mgb;
            case 4:
                return this->_interface;
            case 5:
                return this->_serialnum;
            case 6:
                return this->_driver;
            case 7:
                return this->_devicefiles;
            case 8:
                return this->_config;
            case 9:
                return this->_hwclass;
        }
        return this->_prodname;
    }

    diskInfor::diskInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

/**************************************************/
    QString& bluetoothInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_prodname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_driver;
            case 3:
                return this->_interface;
            case 4:
                return this->_spped;
            case 5:
                return this->_hwclass;
            case 6:
                return this->_config;
            default:
                return this->_prodname;
        }
    };

    bluetoothInfor::bluetoothInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}
/*************************************************/

    QString& keyboardInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_probname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_model;
            case 3:
                return this->_interface;
            case 4:
                return this->_hwclass;
            case 5:
                return this->_config;
            default:
                return this->_probname;
        }
    }

    keyboardInfor::keyboardInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}
/****************************************************/

    QString& soundcardInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_probname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_model;
            case 3:
                return this->_version;
            case 4:
                return this->_ability;
            case 5:
                return this->_config;
            case 6:
                return this->_mhz;
            case 7:
                return this->_dataw;
        }
        return this->_probname;
    }

    soundcardInfor::soundcardInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

/**************************************************/
    batteryInfor::batteryInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

    QString& batteryInfor::GetItem(int itemindex)
    {
        switch (itemindex)
        {
            case 0:
                return this->_probname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_serialnum;
            case 3:
                return this->_state;
            case 4:
                return this->_percentage;
            case 5:
                return this->_cur_energy;
            case 6:
                return this->_energy_full;
            case 7:
                return this->_energy_full_desgin;
            case 8:
                return this->_energy_rate;
            case 9:
                return this->_voltage;
            case 10:
                return this->_capacity;
            case 11:
                return this->_updatedtime;
            default:
                return this->_probname;
        }
    }

/***************************************************/

    mouseInfor::mouseInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

    QString& mouseInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_probname;
            case 1:
                return this->_vendorname;
            case 2:
                return this->_model;
            case 3:
                return this->_interface;
            case 4:
                return this->_hwclass;
            case 5:
                return this->_config;
            default:
                return this->_probname;
        }
    }
/*************************************************/
static QStringList KetWords;
    osInfor::osInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

    QString& osInfor::GetItem(int itemindex)
    {
        switch(itemindex)
        {
            case 0:
                return this->_machinename;
            case 1:
                return this->_vendor;
            case 2:
                return this->_osname;
            case 3:
                return this->_ostype;
            case 4:
                return this->_osversion;
            case 5:
                return this->_kerneltype;
            case 6:
                return this->_kernelversion;
            case 7:
                return this->_cpuinfor;
            case 8:
                return this->_UUID;
            default:
                return this->_machinename;
        }
    }

/*************************************************/

    QString& userInfor::GetItem(int itemindex)
    {
        switch (itemindex)
        {
            case 0:
            return this->_username;
            case 1:
                return this->_tty;
            case 2:
                return this->_logtime;
            case 3:
                return this->_pcpu;
            case 4:
                return this->_what;
            default:
                return this->_username;
        }
    }

    userInfor::userInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}

    ipInfor::ipInfor(uint16_t index,ToolCode code):BaceInfor(code,index){}
}

namespace Yzty {
    //将命令行的输出序列化
    QMap<QString,QString> SerializaShellInput(const QString& command,int& items)
    {
        FILE* fp=popen(command.toStdString().c_str(),"r");          //将命令行输出的内容存入临时文件缓存区,fp指向缓存区

        if(fp==nullptr)
        {
            std::cerr<<"[ERROR] exculte "<<command.toStdString()<<std::endl;
            throw command+"=error";
        }

        QMap<QString,int> cnts;
        QMap<QString,QString> infors;
        QTextStream fstream(fp);                                    //将文件指针封装成流形式，便于输入输出

        QString prek;
        int flag=-1;            //特殊标记

        while(!fstream.atEnd())
        {
            QString&& Line=fstream.readLine().simplified();
            int p=Line.indexOf(QChar(':'));
            QStringList temp({QString(Line.toStdString().substr(0,size_t(p)).c_str()),
                              QString(Line.toStdString().substr(size_t(p+1),size_t(Line.size()-p)).c_str())});
            if(temp.size()>0)   temp[0]=temp[0].simplified();
            if(temp.size()>1)   temp[1]=temp[1].simplified();
            if(temp.size()>2||temp[0].isEmpty()||(flag==-1&&temp.size()==1))        //多项，或者key字段为零  不分析
                continue;
            else if(temp.size()==1)
                infors[prek]+=temp[0]+"\n";
            else
            {
                cnts[temp[0]]++;
                items=qMax(cnts[temp[0]],items);
                if(infors.count(temp[0]))   //若含有重复的key　则加上数字以示区别
                    temp[0]+=QString::number(cnts[temp[0]]);

                infors[temp[0]]="";
                if(temp[1].isEmpty())       //后续有跟进行的　进行特殊标记
                {
                    flag=0x3f;
                    prek=temp[0];
                }else
                    infors[temp[0]]=temp[1];
            }
        }
        return infors;
    }
}

/******************************************安全检查*************************************************/
namespace Yzty
{
SysShareDirInfor::SysShareDirInfor(uint16_t mcode,ToolCode tcode):BaceInfor(tcode,mcode),_infors(int(NUMS)){

}

NetLoginInfor::NetLoginInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

SysUpdateInfor::SysUpdateInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

NetPortInfor::NetPortInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

AccountSecInfor::AccountSecInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

PwdConfigInfor::PwdConfigInfor(uint16_t mcode,ToolCode tcode):BaceInfor(tcode,mcode),_infors(int(NUMS)){

}

NetConfig::NetConfig(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

SecAuditInfor::SecAuditInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

SudoConfigInfor::SudoConfigInfor(uint16_t mcode,ToolCode tcode):BaceInfor(tcode,mcode),_infors(int(NUMS)){

}

NetFireWallInfor::NetFireWallInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

SysProcessInfor::SysProcessInfor(uint16_t mcode,ToolCode tcode):BaceInfor(tcode,mcode),_infors(int(NUMS)){

}

SysServerInfor::SysServerInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

SysKernelInfor::SysKernelInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

EmailInfor::EmailInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

VirMachine::VirMachine(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

DefendSoft::DefendSoft(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

UserLoginInfor::UserLoginInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

WebHistoryInfor::WebHistoryInfor(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

WebDownload::WebDownload(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

WebCollect::WebCollect(uint16_t mcode,ToolCode tcode):BaceInfor (tcode,mcode),_infors(int(NUMS)){

}

WebCookiesInfor::WebCookiesInfor(uint16_t mcode,ToolCode tcode):BaceInfor(tcode,mcode),_infors(int(NUMS)){

}

}

/***************************************文件检查类型定义**********************************************/
namespace Yzty
{
    QStringList FileTypeLimit::TypeNames
    {
        "txt","html","xml","doc","xls","ppt","wps","et","dps",
        "odt","ods","odp","jpg","bmp","png","docx","xlsx","pptx","pdf","rtf","dot","pig","psd","raw"
    };

    FileCheckRecord::FileCheckRecord(FileToolCode index,ToolCode tcode):BaceInfor (tcode,quint16(index))
    {
        _filename_flag=false;
    }

    FileRecordInfor::FileRecordInfor(FileToolCode index,ToolCode tcode):BaceInfor (tcode,quint16(index)){

    }
}


/*******************************************深度检查************************************************/
namespace Yzty {
    UsbOperatorRecord::UsbOperatorRecord(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }

    FileOperator::FileOperator(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }
}

/*******************************************虚拟机检查************************************************/

namespace Yzty {
    VirFileBaceInfor::VirFileBaceInfor(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }
}


/*******************************************邮箱检查************************************************/

namespace Yzty {
    EmailBaceInfor::EmailBaceInfor(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }

    EmailHitInfor::EmailHitInfor(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }

    JugEmailOther::JugEmailOther(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }

    JugEmaililleg::JugEmaililleg(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }

    PWEmailExFile::PWEmailExFile(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor (code,uint16_t(mcode)){

    }

    PWEmailExFMT::PWEmailExFMT(Yzty::ITEMCODE mcode,Yzty::ToolCode code):BaceInfor(code,uint16_t(mcode)){

    }
}






